package models;

import java.util.Date;

import play.data.binding.As;
import siena.DateTime;
import siena.Generator;
import siena.Id;
import siena.Model;
import siena.Query;

public abstract class Content extends Model {
	
	public enum ContentType { 	
		 PHOTO("photo"), VIDEO("video"), AUDIO("audio"), LINK("link"); 
		
		 private String name;
		
		 ContentType(String n) {
			this.name = n;
		}
		
		public String getName() {
			return this.name;
		}
	}
	
	@Id(Generator.AUTO_INCREMENT)
	public Long id;
	@DateTime
    @As(value="dd/MM/yyyy")
	public Date created_time;
	@DateTime
    @As(value="dd/MM/yyyy")
	public Date updated_time;
	public User owner;
	
	public static <T extends Content> Query<T> all(Class T) {
		return Model.all(T);
	}
	
	public static <T extends Content> T findById(Class<T> clazz, Long id) {
		return (T) all(clazz).filter("id", id).get();
	}
	
	
}